package com.codeforces.gym.g100095;

import java.io.File;
import java.io.FileWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class D {

	static Scanner scanner;
	static FileWriter writer;
	static int n, count;
	static double sumexp;
	static dice[] dices;

	public static void main(String[] args) throws Exception {
		scanner = new Scanner(new File("dice.in"));
		writer = new FileWriter(new File("dice.out"));
		n = scanner.nextInt();
		dices = new dice[n];
		count = 0;
		sumexp = 0;
		for (int i=0;i<n;++i) {
			int nface = scanner.nextInt();
			count += nface;
			dices[i] = new dice(nface, i);
		}
		Arrays.sort(dices, new Comparator<dice>() {

			public int compare(dice d1, dice d2) {
				if (d1.nface == d2.nface) {
					return d1.idx - d2.idx;
				}
				else return d1.nface - d2.nface;
			}
			
		});
		
		for (int i=0;i<n;++i) {
			for (int j=0;j<dices[i].nface;++j) {
				dices[i].sum += count;
				dices[i].faces[j] = count;
				count--;
			}
			dices[i].exp = (double) dices[i].sum / (double) dices[i].nface;
			sumexp += dices[i].exp;
		}
		
		Arrays.sort(dices, new Comparator<dice>() {

			public int compare(dice d1, dice d2) {
				return d1.idx - d2.idx;
			}
			
		});
		writer.write(String.format("%.8f\n", sumexp));
		for (int i=0;i<n;++i) {
			for (int j=0;j<dices[i].nface;++j) {
				Arrays.sort(dices[i].faces);
				if (j == dices[i].nface - 1) {
					writer.write(dices[i].faces[j] + "\n");
				}
				else {
					writer.write(dices[i].faces[j] + " ");
				}
			}
		}
		writer.close();
	}

}
class dice {
	int nface;
	int[] faces;
	int idx;
	int sum;
	double exp;
	dice(int nface, int idx) {
		this.nface = nface;
		this.idx = idx;
		this.faces = new int[nface];
		this.sum = 0;
		this.exp = 0;
	}
}